/* 
 * File:   Tile.cpp
 * Author: chb
 * 
 * Created on 5. September 2009, 11:51
 */

#include "Tile.h"


Tile::Tile(const unsigned int posX, const unsigned int posY):MapSite(posX, posY) {
    _content = 0;
}

Tile::Tile(const Tile& orig) {
}

Tile::~Tile() {
    delete _position;
}

void Tile::enter(Movable *m){

    if(m->getLocation() != 0)
        m->getLocation()->leave();
    
    m->setLocation(this);
    _content = m;

    paint(View::instance());
}

void Tile::leave() {
    _content = 0;
    paint(View::instance());
}

void Tile::paint(View* v) const {
    v->drawGraphic(getPosition(), "tile");

    if(_content != 0) {
        _content->paint(v);
    }
}

MapSite* Tile::clone(unsigned int x, unsigned int y) const {
    return new Tile(x, y);
}

MapSite::MS_TYPE Tile::getType() const{
    return MS_TILE;
}

bool Tile::isEmpty(){
    return _content == 0;
}

bool Tile::isFull(){
    return !isEmpty();
}
